<template>
	<view>
		<!-- <cc-myTabbar :tabBarShow="1"></cc-myTabbar> -->
		<view class="poimg" @click="gotofenx">
			<up-swiper :list="list1" height="344rpx"></up-swiper>
			<!-- <image class="poimg" src="/static/logo.png" mode=""></image> -->
		</view>
		<view class="listbox">
			<view class="listanv" v-for="(item,index) in list" :key="index" @click="gotobay(item)">
				<image class="listpic" :src="item.image" mode=""></image>
				<view class="litit">{{item.name}}</view>
				<view class="itext">{{item.intro}}</view>
				<view class="lipion">
					<view class="pionte">现价:{{item.member_price}} <text style="font-size: 14px;"></text></view>
					<view class="liliu">原价:{{item.original_price}}</view>
				</view>
			</view>
		</view>
		<view style="height:140rpx;"></view>
	</view>
	<cc-myTabbar :tabBarShow="1"></cc-myTabbar>
</template>

<script setup>
import {onReady} from '@dcloudio/uni-app'
import { ref,onMounted } from 'vue';
import request from '../../utils/request';
import {onLoad, onReachBottom} from '@dcloudio/uni-app'
onLoad(()=>{
	getData()
	request.get('index/getSlides',{
		date:{
			type:'shop'
		}
	}).then(res=>{
		console.log(res);
		console.log(res.data);
		list1.value = res.data.map(item => item.image);
		console.log(list1.value);
	}).catch(err=>{
		console.log(err);
	})
})
let list1 =ref([])
let list=ref([])
let page = ref(1)
let last_page = ref(1)

onReachBottom(() => {
		if(page.value == last_page.value){
			uni.$u.toast('已经是最后一页了')
		}else{
			page.value++
			getData()
		}
	})
	
const getData = () => {
	if (page.value == 1) {
		list.value = []
	}
	request.get('Productlists/listsByField', {data:{
		page: page.value
	}}).then(res=>{
		last_page.value = res.data.last_page
		if (res.code == 1) {
			res.data.data.forEach((item,index) => {
				list.value.push(item)
			})
		} else {
			uni.showToast({
				title:res.msg,
				icon:'none'
			})
		}
	}).catch(err=>{
		console.log(err);
	})
}

const gotobay=(item)=>{
	const id=item.id
	console.log(id);
	uni.navigateTo({
		url:`/pages/seller/seller?id=${id}`
	})
}
const gotofenx=()=>{
	uni.navigateTo({
		url:'/pages/andings/andings'
	})
}
	onReady(()=>{
		uni.hideTabBar();
	})
</script>

<style scoped>
	page {
		padding-bottom: 140rpx;
	
	}
	.poimg{
		width: 712rpx;
		height: 344rpx;
		margin: 40rpx auto;
	}
	.listanv{
		width: 350rpx;
		height: 550rpx;
		margin-left: 20rpx;
		margin-top: 20rpx;
		background-color: #FFF;
		}
	.listpic{
		width: 350rpx;
		height: 350rpx;
		display: block;
		border-radius: 0 10rpx 10rpx 0;
	}
	.listbox{
		display: flex;
		flex-wrap: wrap;
		background-color: #f9f9f9;
	}
	.litit{
		margin-top: 16rpx;
		padding-left: 15rpx;
		white-space: nowrap; /* 防止文本换行 */
		overflow: hidden;    /* 超出部分隐藏 */
		text-overflow: ellipsis;
	}
	.itext{
		padding-left: 15rpx;
		height: 32rpx;
		box-sizing: border-box;
		white-space: nowrap; /* 防止文本换行 */
		overflow: hidden;    /* 超出部分隐藏 */
		text-overflow: ellipsis;
		color: #b3a6a6;
		font-size:12px;	
		margin-top: 10rpx;
		margin-bottom:20rpx;
		}
		.lipion{
			display: flex;
			align-items:  flex-end;
			justify-content: space-around;
		}
		.pionte{
			color:#10c6b1;
			font-size: 14px;
		}
		.liliu{
			font-size: 10px;
		}
</style>
